﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TakeoutExpress.Support.Controllers;
namespace TakeoutExpress2008.Web.MVC.Components
{
    public class BasePage : System.Web.UI.Page
    {

        protected int SiteID {
            get
            {
                if (Session["currentSiteId"] != null)
                    return int.Parse(Session["currentSiteId"].ToString());
                else
                    return new SiteController().GetDefaultSite().SiteID;
            }
        }

        protected Control FindControlRecursive(Control root, string id)
        {
            if (root.ID == id)
            {
                return root;
            }

            foreach (Control c in root.Controls)
            {
                Control t = FindControlRecursive(c, id);
                if (t != null)
                {
                    return t;
                }
            }

            return null;
        } 

    }
}
